using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Globalization;
using System.Threading;

namespace mmq
{
    public class BasePage : System.Web.UI.Page
    {
        protected override void InitializeCulture()
        {
            // override virtual method InitializeCulture() to check if profile contains a user language setting
            string UserCulture = HttpContext.Current.Profile.GetPropertyValue("PreferredCulture").ToString();
            SetCulture(UserCulture);
            HttpContext.Current.Profile.SetPropertyValue("PreferredCulture", Thread.CurrentThread.CurrentCulture.Name);
        }
        private void SetCulture(string cultureName)
        {
            string strCultureSupported = "en-USZzh-CN";
            if (!strCultureSupported.Contains(cultureName))
            {
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
            }
            else
            {
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureName);
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cultureName);
            }
        }
        public virtual String MetaKeyword
        {
            get
            {
                HtmlMeta _MetaControl = (HtmlMeta)this.Page.Header.FindControl("MetaKeyword");
                return (_MetaControl.Content);
            }
            set
            {
                HtmlMeta _MetaControl = (HtmlMeta)this.Page.Header.FindControl("MetaKeyword");
                _MetaControl.Content = value;
            }
        }
        public virtual String Description
        {
            get
            {
                HtmlMeta _MetaControl = (HtmlMeta)this.Page.Header.FindControl("Description");
                return (_MetaControl.Content);
            }
            set
            {
                HtmlMeta _MetaControl = (HtmlMeta)this.Page.Header.FindControl("Description");
                _MetaControl.Content = value;
            }
        }

    }

}
